package com.wd.live.view;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.wd.live.R;
import com.wd.live.base.BaseActivity;
import com.wd.live.base.BaseViewModel;
import com.wd.live.databinding.ActivitySussceRzBinding;
import com.wd.live.bean.RZMessageBean;
import com.wd.live.model.SpUtils;
import com.wd.live.model.utils.ToastFormat;
import com.wd.live.viewmodel.SussceRzViewModel;

public class SussceRzActivity extends BaseActivity<SussceRzViewModel, ActivitySussceRzBinding> {


    @Override
    protected void initData() {
        ToastFormat.setText("已经认证完成过了哦(〃'▽'〃)");
        ToastFormat.show();
        databind.xinFan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(SussceRzActivity.this,UserMessageActivity.class));
                finish();
            }
        });
        viewmodel.getList().observe(this, new Observer<RZMessageBean>() {
            @Override
            public void onChanged(RZMessageBean rzMessageBean) {
                RZMessageBean.ResultBean result = rzMessageBean.getResult();
                databind.rzName.setText(result.getActualName());
                SpUtils.putString("acName",result.getActualName());
                int sex = result.getSex();
                if(sex==1){
                    databind.rzsex.setText("男");
                }else{
                    databind.rzsex.setText("女");
                }
                String idNumber = result.getIdNumber();
                String s = hideId(idNumber);
                databind.rzId.setText(s);
            }
        });
    }

    @Override
    protected int initLayout() {
        return R.layout.activity_sussce_rz;
    }

    @Override
    public void onChanged(Object o) {

    }
    public static String hideId(String id) {
        String idNum = id.replaceAll("(\\d{4})\\d{10}(\\d{4})", "$1****$2");
        return idNum;
    }

    @Override
    protected void onPause() {
        super.onPause();
        startActivity(new Intent(SussceRzActivity.this,UserMessageActivity.class));
        finish();
    }
}